package adapter

import "fmt"

type MediaPlayer interface {
	Play(audioType, fileName string)
}

type OldPalyPlayer struct {
}

func (player OldPalyPlayer) Play(audioType, fileName string) {
	fmt.Println("旧的播放器", audioType, fileName)
}

type IAdvanceMediaPlayer interface {
	PlayRmvb(fileName string)
	PlayMP4(fileName string)
}

type AdvanceMediaPlayer struct {
}

func (a AdvanceMediaPlayer) PlayRmvb(fileName string) {
	fmt.Println("新播放器PlayRmvb", fileName)
}
func (a AdvanceMediaPlayer) PlayMP4(fileName string) {
	fmt.Println("新播放器PlayMP4", fileName)
}

type AdapterMediaPlayer struct {
	advMp IAdvanceMediaPlayer
}

func (adapt AdapterMediaPlayer) Play(audioType, fileName string) {
	switch audioType {
	case "mp4":
		adapt.advMp.PlayMP4(fileName)
	case "rmvb":
		adapt.advMp.PlayRmvb(fileName)
	}
}

func GetPaly() MediaPlayer {
	return OldPalyPlayer{}
}

func GetAdvPaly() MediaPlayer {
	return AdapterMediaPlayer{
		advMp: AdvanceMediaPlayer{},
	}
}
